#!/bin/bash
PROD=build/production/cloud
PACK=build/${PWD##*/}/package

if [ -z $1 ]; then
echo 'missing a parameter'
echo 'HELP:'
echo gen : sencha generate app $2 ../$2
echo prod : sencha app build production
echo package : sencha app build production
echo css : compass compile resources/sass/
echo android : sencha app package run android
exit
fi

if [ $1 = gen ]; then
echo sencha generate app $2 $2 --sdk-path=/Users/rome/projects/sencha/sencha-touch/
sencha --sdk-path=/Users/rome/projects/sencha/sencha-touch/ generate app $2 $2
fi

if [ $1 = server ]; then
rm -rf $PROD
echo sencha app build package
sencha app build production
cp -rf loadImg.js $PROD/
cp -rf login* $PROD/
cp -rf nicEdit* $PROD/
rm -rf $PROD/login/.svn
rm -rf $PROD/login/css/.svn
rm -rf $PROD/login/js/.svn
rm -rf $PROD/login/images/.svn
fi

if [ $1 = release ]; then
rm -rf server.tar.gz
echo release package
#sed -i -e "s/cloud\.appmars\.com/115.28.36.217/g" "$PACK/index.html"
#sed -i -e "s/cloud\.appmars\.com/115.28.36.217/g" "$PACK/login.html"
#rm -rf $PACK/*-e
cd $PROD && tar zcvf ../../../server.tar.gz .
cd ../../../
scp server.tar.gz root@192.168.9.182:/alidata/www/yunkelai/wifi/
fi

if [ $1 = dis ]; then
rm -rf server.tar.gz
echo release package
cd $PACK && tar zcvf ../../../server.tar.gz .
cd ../../../
scp server.tar.gz root@xayoudao.com:/alidata/www/
ssh root@xayoudao.com '/alidata/www/testadmin.sh'
fi



if [ $1 = prod ]; then
echo sencha app build production
sencha app build production
fi

if [ $1 = package ]; then
echo sencha app build package
sencha app build package
fi

if [ $1 = css ]; then
echo compass compile resources/sass/
compass compile resources/sass/
fi

if [ $1 = watch ]; then
echo compass compile resources/sass/
compass watch resources/sass/
fi

if [ $1 = android ]; then
echo delete _android.buit and sencha app package
rm _android.built
rm -rf build/${PWD##*/}/android
sencha app build production
fi

if [ $1 = ios ]; then
echo sencha app build package
rm _ios.built
rm -rf build/${PWD##*/}/ios
sencha app build production
fi

echo success!
say success! &
## afplay ~/bin/notice.mp3 &
